<extend name="work/base"/>
<block name="content">
    <header class="wx-header">
        <h1 class="wx-title">失物信息列表</h1>
    </header>
    <div class="weui-cells__tips" style="color:#e64340;"> <a  href="https://mp.weixin.qq.com/s?__biz=MzIyNzI2Mjc3OA==&mid=100000419&idx=1&sn=989f80b27092476694f61b44205ae564&chksm=6862aaf65f1523e0d2d6e21a8713ab2146b326b5ab22e998768e1bfb37614caf9eeb06f9c39e#rd " >{:config('param.lose_info')}</a> </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>电话</th>
            <th>时间</th>
            <th>详情</th>

        </tr>
        </thead>
        <tbody id="order_list">


        </tbody>
    </table>
    <div class="weui-loadmore">
        <i class="weui-loading"></i>
        <span class="weui-loadmore__tips">正在加载...</span>
    </div>
</block>
<block name="script">
    <script src="__PUBLIC__/js/doT.min.js"></script>
    <script id="listtmpl" type="text/template">
        {{~ it.data:item:index }}
        <tr >

      <td data-label="电话"> {{=item.phone}}</td>
      <td data-label="时间">
          {{? item.add_time==0}}
          ----
          {{??}}
          {{=new Date(item.add_time*1000).Format("yyyy-MM-dd hh:mm")}}
          {{?}}
      </td>
        <td data-label="详情"> {{=item.info}}</td>
        </tr>
        {{~ }}
    </script>
    <script type="text/javascript">
        Date.prototype.Format = function(fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "h+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            var now = new Date();
            var now_new = Date.parse(now);

                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                for (var k in o)
                    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                return fmt;

        }

        $(document).ready(function () {
            $(document.body).infinite();
            var loading = false;  //状态标记
            var limit = 1;
            var newlist = doT.template($('#listtmpl').html());
             updatelist();
            $(document.body).infinite().on("infinite", function () {
                 updatelist();
            });

            function updatelist() {
                if (loading) return;
                loading = true;
                $.ajax({
                    type: 'get',
                    dataType: "json",
                    url: '{:url("lists")}',
                    data: {page: limit},
                    success: function (res) {
                        if (res.code === 0) {
                            $("#order_list").append(newlist(res));
                            limit+=1;
                        } else {
                            $.toast(res.msg, "cancel");
                            $(".weui-loadmore").hide();
                            $(document.body).destroyInfinite();
                        }
                        loading = false;
                    },
                    error: function () {
                        $.toast('发生错误,请检测网络', "cancel");
                        loading = false;
                    },

                });
            }









        });
    </script>
</block>
